<template>
  <el-dialog 
    title='管理'
    :class='[{"big":dialogShowIf},"node-manage-edit-dialog"]'
    :visible.sync="visible"
    @close='handleClose'
    @open='handleOpen'
    top='24vh'
    size='tiny'
    >
    <div class="form-wrap">
      <el-form ref='detailManageForm' :model='form' :rules="rules" label-position='left' label-width="110px">

        <el-form-item label='休假年份' prop='year'>
          
          <el-date-picker
            v-model="form.year"
            @change='(val)=>this.form.year=val'
            format="yyyy"
            type="year"
          />

        </el-form-item>

      </el-form>
      
    </div>

    <span slot="footer">
      <el-button type='primary' @click.stop="handleSure('detailManageForm')">保 存</el-button>
    </span>

  </el-dialog>
</template>

<script>
import Vue from 'vue'
import { Message, DatePicker } from 'element-ui'
Vue.use(DatePicker)
import Bus from './bus'
export default {

  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data () {



    const rule_assigneeType = (rule, value, callback) => {

      if (!value) {
        return callback(new Error('请选择执行单位类型'))
      }



      callback()
    }

    return {
      visible: false,
      dialogShowIf: false,
      form: {
        year: []
      },
      rules: {
        year: [
          {
            required: true, message: '请选择日期', trigger: 'submit'
          }
        ]
      }
    }
  },

  computed: {
    ruleId () {
      return this.$route.query.id || ''
    }
  },


  watch: {
    dialogVisible (newValue) {
      this.visible = newValue
    }
  },

  mounted () {
  },
  methods: {

    handleOpen () {
      this.form.year = ''
    },


    handleClose () {
      this.$emit("update:dialogVisible", false)
    },

    handleSure (formName) {

      this.$refs[formName].validate((valid) => {
        if (valid) {

          const params = {
            ruleId: this.ruleId,
            year: parseInt(this.form.year)
          }

          this.Axios
            .Post('/wfConfVacationRoutine/addBatchRecord', params)
            .then(res => {

              if (res.data.status == 1) {

                Message({
                  type: 'success',
                  message: res.data.message
                })

                Bus.$emit('refresh', Math.random())

              }

              this.handleClose()
            })

        } else {

          return false
        }
      })
    },

  },
}
</script>
